/*
 * MIT License
 *
 * Copyright (c) 2020 Mr.css
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 */

package cn.seaboot.postman.response;

import cn.seaboot.common.reflect.ObjectType;

import java.util.List;
import java.util.Map;

/**
 * ResponseBody字段
 * <p>
 * It is designed by us, the {@link BodyField} is use for writing description of Response,
 * {@link Response#setBody(String body)}
 *
 * @author Mr.css
 * @date 2020-12-24 20:19
 */
public class BodyField {
    /**
     * field type
     */
    private ObjectType objectType;

    /**
     * field name
     */
    private String fieldName;
    /**
     * field example
     */
    private String example;
    /**
     * field description
     */
    private String description;
    /**
     * Hibernate-validator，因为不是原生的字段，所以加了横杠前缀
     */
    private List<Map<String, Object>> _validator;
    /**
     * field，如果字段类型是Object，那会包含子节点
     */
    private Map<String, BodyField> fields;

    public ObjectType getObjectType() {
        return objectType;
    }

    public void setObjectType(ObjectType objectType) {
        this.objectType = objectType;
    }

    public String getFieldName() {
        return fieldName;
    }

    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public String getExample() {
        return example;
    }

    public void setExample(String example) {
        this.example = example;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<Map<String, Object>> get_validator() {
        return _validator;
    }

    public void set_validator(List<Map<String, Object>> _validator) {
        this._validator = _validator;
    }

    public Map<String, BodyField> getFields() {
        return fields;
    }

    public void setFields(Map<String, BodyField> fields) {
        this.fields = fields;
    }

    @Override
    public String toString() {
        return "BodyField{" +
                "objectType=" + objectType +
                ", fieldName='" + fieldName + '\'' +
                ", example='" + example + '\'' +
                ", description='" + description + '\'' +
                ", _validator=" + _validator +
                ", fields=" + fields +
                '}';
    }
}
